home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / ENCRYPT.SWG / 0011_PASSWORD.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  81 lines

  1. { JL>Help me guys. I'm learning about reading from a File. I am creating a
  2.  JL>Program that will let you set passWord and test a passWord.
  3.  
  4.  JL>Also how do you make the screen print a Character like .... instead of a
  5.  JL>Word.  So when you enter in a passWord like in BBS it won't show it?
  6.  
  7. ------------------------------------X----------------------------------------
  8. }
  9.  
  10. Program TestPW;
  11.  
  12. {
  13. Programmer      : Chet Kress (FidoNet 1:283/120.4)
  14. Been Tested?    : YES, this has been tested.  It works!
  15. original Date   : 01/01/93
  16. Current Version : v1.0
  17. Language        : Turbo Pascal v7.0
  18. Purpose         : Make a passWord routine
  19. }
  20.  
  21. Uses Crt;
  22.  
  23. Procedure TestPassWord;
  24.  
  25. Const
  26.   DataFile = 'PW.DAT'; {The name of the data File containing the passWord}
  27.   {Just have one line in the PW.DAT File, and use that as the passWord}
  28.  
  29. Var
  30.   PassWordFile : Text; {The name assigned to the data File}
  31.   PassCH : Char; {A Character that the user has entered}
  32.   TempPassWord : String; {The temporary passWord from the user}
  33.   ThePW : String; {The Real passWord from the data File}
  34.  
  35. begin {TestPassWord}
  36.   Assign (PassWordFile, DataFile);
  37.   Reset (PassWordFile);
  38.   ClrScr;
  39.   TempPassWord := '';
  40.   Write ('Enter passWord: ');
  41. {
  42.   I replaced the Readln With this Repeat..Until loop so you can see the
  43.   "periods" instead of the Characters (like you wanted).  This is a simple
  44.   routine, but it should suffice For what you want it to do.  It has some
  45.   error checking and backspacing is available too.
  46. }
  47.   Repeat
  48.     PassCH :=  ReadKey;
  49.     if (PassCH = #8) and (Length(TempPassWord) > 0) then
  50.       begin
  51.         Delete (TempPassWord, Length(TempPassWord), 1);
  52.         GotoXY (WhereX-1, WhereY);
  53.         Write (' ');
  54.         GotoXY (WhereX-1, WhereY);
  55.       end;
  56.     if (PassCH >= #32) and (PassCH <= #255) then
  57.       begin
  58.         TempPassWord := TempPassWord + PassCH;
  59.         Write ('.');
  60.       end;
  61.   Until (PassCH = #13);
  62.   Writeln;
  63.   Readln (PassWordFile, ThePW);        { <-- You Forgot to add this line }
  64.   if TempPassWord = ThePW then
  65.     begin
  66.       Writeln ('You have received access.');
  67.       Writeln ('Loading Program.');
  68.       { Do whatever else you want to here }
  69.     end
  70.   else
  71.     begin
  72.       Writeln ('Wrong PassWord.');
  73.     end;
  74.   Close (PassWordFile);
  75. end; {TestPassWord}
  76.  
  77. begin {Main}
  78.   TestPassWord;
  79. end. {Main}
  80.  
  81.